package com.sline.test;

import java.io.File;

public class DirectoryDelete {
    public static void main(String[] args) {

        File dir = DirectorySize.getFile();

        deleteDir(dir);
    }

    // 删除目录下的所有文件
    public static void deleteDir(File dir) {
        File[] subFiles = dir.listFiles();

        for (File subFile: subFiles) {
            if (subFile.isFile()) {
                subFile.delete();
            } else if (subFile.isDirectory()) {
                deleteDir(subFile);
            }
        }

        dir.delete();
    }
}
